<include file="Public:header" />
<!--<script type="text/javascript" src="__PUBLIC__/js/kindeditor-all-min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/zh_CN.js"></script>
<link rel="stylesheet" href="__PUBLIC__/css/kindeditor.css" type="text/css" />
<script type="text/javascript">
	<if condition="C('ismobile') neq 1">
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content"]', {
				uploadJson:'__APP__/index.php/File/editor/',
				allowFileManager : true,
				loadStyleMode : false,
				fileManagerJson: "__APP__/index.php/File/manager/"
			});
		});
	</if>
</script>-->
<div class="container">
	<div class="page-header">
		<h4>新增 资讯信息</h4>
	</div>
	<div class="row">
		<div class="span12">
			<include file="Public:alert" />
			<form action="__APP__/index.php/News/add/" method="post" enctype="multipart/form-data">
				<input  type="hidden" name="role_id" value="{$Think.session.role_id}"/>
				<table class="table" border="0" cellspacing="1" cellpadding="0">
					<thead>
						<tr>
							<td colspan="2"><input name="submit" class="btn btn-primary" type="submit" value="保存"/>&nbsp; <input class="btn btn-primary" name="submit" type="submit" value="保存 & 新增"/> &nbsp;<input class="btn" type="button" onclick="javascript:history.go(-1)" value="返回"/></td>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="2"><input class="btn btn-primary"  name="submit" type="submit" value="保存"/> &nbsp;<input class="btn btn-primary" type="submit" value="保存 & 新增"/>&nbsp; <input class="btn" type="button" onclick="javascript:history.go(-1)" value="返回"/></td>
						</tr>
					</tfoot>
					<tbody>
						<tr>
							<td class="tdleft">目录</td>
							<td>
								<select name="category_id">
								    <option value="">选择目录</option>
									<volist  name="category_list" id="vo">
									<option value="{$vo.id}">{$vo.name}</option>
									</volist>
								</select>
							</td>
						</tr>
						<tr>
							<td class="tdleft">文章标题</td>
							<td><input class="span3" type="text" name="title" id="title" size="80" placeholder="请输入标题"></td>
						</tr>
						<tr>
							<td class="tdleft">标题图片</td>
							<td>
								
								<div>
								<p>图片预览：</p>
								<img id="thumbs" style="max-width:240px;max-height:80px;" src="
								<?php if(!empty($vo['large_thumb'])){?>
								<?php echo 'http://'.FRONT_SITE_NAME.str_replace('./','/',$vo['large_thumb']);?>" 
								<?php }?>
								/>
								</div>
								<div style="clear:both;width:100%;height:1px;"></div></br>
								<div>

									<p>
										<input type="hidden" name="images_url" id="url1" value="" />
										<input type="button" id="image1" value="选择图片" />
									</p></br>

								</div>
								
								<!--<style>
								.ncbtn{
								font: 400 12px/20px "microsoft yahei",arial;
								color: #FFF;
								background-color: #ffc314;
								text-align: center;
								vertical-align: middle;
								display: inline-block;
								height: 30px;
								padding: 5px 10px;
								border-radius: 3px;
								cursor: pointer;
								text-decoration: none;
								}

								#tabs>div img{margin:5px;}
								#tabs>div img:hover{cursor:pointer;}
								</style>
								<div>
										2.从相册中选择图片
										<a class="ncbtn picture_insert">打开相册</a>
										<a class="ncbtn picture_close">关闭相册</a>
									<input type="hidden" id="images_url" name="images_url" value=""/>
								</div>-->
								<div id="tabbox" style="width:800px;display:none;">
									<div id="tabs">
									  <ul></ul>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td class="tdleft">简单描述</td>
							<td>
								<textarea name="meta_description" id="meta_description" style="width: 800px; height: 50px;"></textarea>
							</td>
						</tr>
						<tr>
							<td class="tdleft">详情</td>
							<td>
								<textarea name="content" id="content" style="width: 800px; height: 350px;"></textarea>
							</td>
						</tr>
						<tr>
							<td class="tdleft">排序</td>
							<td><input class="span3" type="text" name="descno" id="descno" placeholder="排序" size="5" value="999"></td>
						</tr>
						<tr>
							<td class="tdleft">首页显示</td>
							<td>
							 <input type="radio" name="istop" value="1" checked>  显示
                              <input type="radio" name="istop" value="0" >  不显示
							</td>
						</tr>
						<tr>
							<td class="tdleft">启用</td>
							<td>
								<input type="radio" name="is_show" value="1" checked>  启用
								<input type="radio" name="is_show" value="0" >  停用
							</td>
						</tr>
					</tbody>
				</table>
			</form>

		</div>
	</div>
</div>
<script type="text/javascript">
	<if condition="C('ismobile') eq 1">
		width=$('.container').width() * 0.9;
		$("#content").css({
			width : width
		});
	</if>
	$("input[name='submit']").click(function(){

		//将编辑器ifreme的值传到textarea
		$("#content").html(editor2.html());
		var content=$("#content").val();
		//alert(content);return false;
		if(content == null || content == ""){
			alert('详情不能为空');
			return false;
		}

		if($("select[name='category_id'] option:selected").val()==null||$("select[name='category_id'] option:selected").val()==""){
			alert("请选择目录");
			return false;
		}
		
	})
	$(".fa-file-text-o").parent().parent().addClass("active");
    $(".fa-indent").parent().parent().addClass("active");
</script>
<!--Kindeditor-->
<script charset="utf-8" src="__PUBLIC__/js/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="__PUBLIC__/js/kindeditor/lang/zh-CN.js"></script>
<script>
	KindEditor.ready(function(K) {
		//文本域编辑器（默认最大宽度为722px，高度等比例）
		var editor2 = K.create('textarea[name="content"]', {
			uploadJson:'__PUBLIC__/js/kindeditor/php/upload_json_news.php?type=1',
			allowFileManager : true,
			//insert_imageWidth:"722", //设置编辑框内默认图片尺寸
			//insert_imageHeight:"80",
			//loadStyleMode : false,
			fileManagerJson: '__PUBLIC__/js/kindeditor/php/file_manager_json_news.php'
		});
		//点击文件元素，弹出kindeditor编辑器的图片窗口，将选择的图片路径存储到隐藏文本中，提交到控制器处理
		K('#image1').click(function() {
			var editor = K.editor({
				//allowFileManager : true,
				uploadJson:'__PUBLIC__/js/kindeditor/php/upload_json_news_thumb.php',
				//loadStyleMode : false,
				fileManagerJson: '__PUBLIC__/js/kindeditor/php/file_manager_json.php'
			});
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					imageUrl : K('#url1').val(),
//					imageWidth:"135",
//					imageHeight:"80",
					clickFn : function(url, title, width, height, border, align) {
						$("#thumbs").attr("src",url)
						url = "/Public"+url.replace(/http.*.\/Public/g,"");
						K('#url1').val(url);
						editor.hideDialog();
					}
				});
			});
		});

	});

</script>
<include file="Public:footer" />